import axios from 'axios';
import config from './config';
import request from '@/utils/request'
let base = config.ApiDomain;
let sbase = config.StaticDomain;
let sid = sessionStorage.getItem('sessionid');
let aid = 0;
let apath = "";
let apiHost = config.ApiDomain;

//获取商品详情
export function SKUList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Product/SKUList',
    method: 'post',
    data,
  })
}

//手机号码登录
export const Login = params => {
  sid = sessionStorage.getItem('sessionid');
  return axios({
    url: 'Master/Login/Login',
    method: 'post',
    data: params,
    transformRequest: [function (data) {
      let ret = '';
      for (let it in data) {
        ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
      }
      return ret
    }],
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  });
};


//获取库存盘点列表
export function WarehouseCheck(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Warehouse/WarehouseCheck',
    method: 'post',
    data,
  })
}

//获取供货商列表
export function GetAnySupplierList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'api/Supplier/GetAnySupplierList',
    method: 'post',
    data,
  })
}

//订货
export function PurchaseOrder(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/PurchaseOrder',
    method: 'post',
    data,
  })
}
//获取采购订货历史列表
export function PurchaseOrderHistoryList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/PurchaseOrderHistoryList',
    method: 'post',
    data,
  })
}
//发货
export function DeliverGoodsBill(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/DeliverGoodsBill',
    method: 'post',
    data,
  })
}
//获取采购发货历史列表
export function PurchaseDeliverGoodsHistoryList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/PurchaseDeliverGoodsHistoryList',
    method: 'post',
    data,
  })
}
//收货
export function WarehouseReceipt(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/WarehouseReceipt',
    method: 'post',
    data,
  })
}
//收货历史列表
export function WarehouseReceiptHistoryList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/WarehouseReceiptHistoryList',
    method: 'post',
    data,
  })
}
//异常单
export function AbnormalBill(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/AbnormalBill',
    method: 'post',
    data,
  })
}
//收货历史列表
export function AbnormalBillList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/AbnormalBillList',
    method: 'post',
    data,
  })
}

//店铺列表
export function Store(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/AgentPurchase/Store',
    method: 'post',
    data,
  })
}

//获取供应商商品列表
export function PurchaseOrderProductList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/SupplierPurchase/PurchaseOrderProductList',
    method: 'post',
    data,
  })
}

//退货
export function ReturnOfTheGoods(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Warehouse/ReturnOfTheGoods',
    method: 'post',
    data,
  })
}

//获得订货建议API
export function GetOrderSugguestion(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: '/Master/AgentPurchase/GetOrderSugguestion',
    method: 'post',
    data,
  })
}

//获得订货建议API
export function PurchaseGetBranchList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseGetBranchList',
    method: 'post',
    data,

  })
}

//获取商品列表
export function PurchaseGetSKUList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseGetSKUList',
    method: 'post',
    data,

  })
}

//获取门店销售数据
export function PurchaseGetBranchSalesData(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseGetBranchSalesData',
    method: 'post',
    data,
  })
}
//获取门店销售数据所有
export function PurchaseGetSalesData(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseGetSalesData',
    method: 'post',
    data,
  })
}
//获取采购历史列表
export function PurchaseGetTotalWarehouseOrderShippedList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseGetTotalWarehouseOrderShippedList',
    method: 'post',
    data,
  })
}

//获取采购详情
export function PurchaseGetTotalWarehouseOrderDetailList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseGetTotalWarehouseOrderDetailList',
    method: 'post',
    data,
  })
}

//获取供货商列表
export function PurchaseGetSupplierList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseGetSupplierList',
    method: 'post',
    data,
  })
}
//添加供货商
export function PurchaseAddSupplier(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseAddSupplier',
    method: 'post',
    data,
  })
}
//启用/禁用供应商
export function PurchaseSwitchSupplier(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseSwitchSupplier',
    method: 'post',
    data,
  })
}
//修改供应商信息
export function PurchaseUpdateSupplier(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseUpdateSupplier',
    method: 'post',
    data,
  })
}
//获取所有商品列表
export function PurchaseGetAllSKUList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseGetAllSKUList',
    method: 'post',
    data,
  })
}
//新增商品
export function PurchaseAddSKU(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseAddSKU',
    method: 'post',
    data,
  })
}
//禁用启用商品
export function PurchaseSwitchSKU(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseSwitchSKU',
    method: 'post',
    data,
  })
}

//获取商品分类列表
export function PurchaseSKUClassList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseSKUClassList',
    method: 'post',
    data,
  })
}

//修改商品信息
export function PurchaseUpdateSKU(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseUpdateSKU',
    method: 'post',
    data,
  })
}

//获取商品证书列表
export function PurchaseSKUCertificateList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseSKUCertificateList',
    method: 'post',
    data,
  })
}
//新增商品证书
export function PurchaseAddSKUCertificate(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseAddSKUCertificate',
    method: 'post',
    data,
  })
}
//删除商品证书
export function PurchaseDeleteSKUCertificate(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseDeleteSKUCertificate',
    method: 'post',
    data,
  })
}
//上传图片
export function PurchaseUploadImage(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/PurchaseUploadImage',
    method: 'post',
    data,
  })
}

//获取采购订单列表
export function GetPurchaseOrdersDetailList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/GetPurchaseOrdersDetailList',
    method: 'post',
    data,
  })
}

//获取采购订单列表
export function GetPurchaseOrdersDetail(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/GetPurchaseOrdersDetail',
    method: 'post',
    data,
  })
}

////修改密码
export function UpdatePassword(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: '/Master/Login/UpdatePassword',
    method: 'post',
    data,
  })
}

//采购--获取收/付款单表头列表
export function Gett_cg_PurchaseMoneyList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/Gett_cg_PurchaseMoneyList',
    method: 'post',
    data,
  })
}

//删除采购订单*
export function DeletePurchaseOrders(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/DeletePurchaseOrders',
    method: 'post',
    data,
  })
}

//新增采购订单
export function AddPurchaseOrders(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/AddPurchaseOrders',
    method: 'post',
    data,
  })
}

//修改采购订单
export function UpdateurchaseOrders(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/UpdateurchaseOrders',
    method: 'post',
    data,
  })
}

//获取采购表头(新增时)
export function GetPurchaseOrdersAdd(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/GetPurchaseOrdersAdd',
    method: 'post',
    data,
  })
}

//店铺下拉2019
export function FinanceStore(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Finance/FinanceStore',
    method: 'post',
    data,
  })
}

//获取验收入库单列表*
export function Gett_cg_PurchaseReceiptList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/Gett_cg_PurchaseReceiptList',
    method: 'post',
    data,
  })
}

//审核采购订单
export function CheckPurchaseOrders(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/CheckPurchaseOrders',
    method: 'post',
    data,
  })
}

//反审采购订单
export function UnCheckPurchaseOrders(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/UnCheckPurchaseOrders',
    method: 'post',
    data,
  })
}

//获取验收入库单表体列表
export function Gett_cg_PurchaseReceiptDetailList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/Gett_cg_PurchaseReceiptDetailList',
    method: 'post',
    data,
  })
}

//新增验货入库单
export function AddPurchaseReceipt(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/AddPurchaseReceipt',
    method: 'post',
    data,
  })
}

//修改验货入库单
export function UpPurchaseReceipt(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/UpPurchaseReceipt',
    method: 'post',
    data,
  })
}

//新增验货入库单
export function CheckPurchaseReceipt(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/CheckPurchaseReceipt',
    method: 'post',
    data,
  })
}

//反审验货入库
export function UnCheckPurchaseReceipt(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/UnCheckPurchaseReceipt',
    method: 'post',
    data,
  })
}

//删除验收入库订单*
export function Deletet_cg_PurchaseReceipt(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/Deletet_cg_PurchaseReceipt',
    method: 'post',
    data,
  })
}

//获取退货出库单列表
export function Gett_cg_PurchaseReturnList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/Gett_cg_PurchaseReturnList',
    method: 'post',
    data,
  })
}
//获取退货出库单详情列表
export function Gett_cg_PurchaseReturnDetailList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/Gett_cg_PurchaseReturnDetailList',
    method: 'post',
    data,
  })
}
//获取退货出库单详情列表
export function AddPurchaseReturn(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/AddPurchaseReturn',
    method: 'post',
    data,
  })
}

//审核退货出库单
export function CheckPurchaseReturn(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/CheckPurchaseReturn',
    method: 'post',
    data,
  })
}

//审核退货出库单
export function UpPurchaseReturn(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/UpPurchaseReturn',
    method: 'post',
    data,
  })
}

//审核退货出库单
export function UnCheckPurchaseReturn(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/UnCheckPurchaseReturn',
    method: 'post',
    data,
  })
}

//删除退货出库单
export function Deletet_cg_PurchaseReturn(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/Deletet_cg_PurchaseReturn',
    method: 'post',
    data,
  })
}

//获取采购未到货列表成功
export function GetPurchaseArrivedList(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/GetPurchaseArrivedList',
    method: 'post',
    data,
  })
}

////获取补货建议(报表)
export function GeReplenishmentProposal(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/GeReplenishmentProposal',
    method: 'post',
    data,
  })
}
////获取采购明细(报表)
export function GePurchaseDetails(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/GePurchaseDetails',
    method: 'post',
    data,
  })
}
////获取采购明细(商品报表)
export function GePurchaseSummaryProduct(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/GePurchaseSummaryProduct',
    method: 'post',
    data,
  })
}
////采购汇总表(报表)
export function GetPurchaseSummary(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/GetPurchaseSummary',
    method: 'post',
    data,
  })
}

////新增配送出库单
export function AddDeliveryOutStock(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Warehouse/AddDeliveryOutStock',
    method: 'post',
    data,
  })
}

//修改商品采购系数
export function UpdatePurchaseRate(data) {
  console.log(data)
  data = '=' + encodeURIComponent(Base64.encode(JSON.stringify(data)))
  return request({
    url: 'Master/Purchase/UpdatePurchaseRate',
    method: 'post',
    data,
  })
}
